<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8" />
		<title>Document</title>
		<meta name="viewport" content=" width=device-width initial-scale=1.0 maximum-scale=1 minimum-scale=1 user-scalable=no viewport-fit=cover">
		<style>
			*{
				margin: 0;
				padding: 0;
			}
			#demo{
				width: 9.2rem;
				height: 4rem;
				margin: 0 auto;
				margin-top: 0.4rem;
				background-color: skyblue;
				border:1px solid black;
			}
		</style>
	</head>
	<body>
		<div id="demo"></div>
		<script type="text/javascript" >
			adapter()
			function adapter(){
				//获取当前设备的屏宽
				const dpWidth = document.documentElement.clientWidth
				//计算根字体
				const rootFontSize = dpWidth / 10
				//设置根字体
				document.documentElement.style.fontSize = rootFontSize +'px'
			}
			window.onresize = adapter
		</script>
	</body>
</html>